<include file="Public:script-load-page" />
<body>
<div class="login"><img src="__PUBLIC__/Weixin/images/logo.png"></div>
<div style="width: 100%;text-align: right;margin-right: 5px">已有帐号？<a href="{:U('login')}">立即登陆</a></div>

<div class="forget_1 login_1">
    <form name="form1" id="form1" method="post">
        <ul>
            <li class="login_line"><img src="__PUBLIC__/Weixin/images/member.png">
                <input name="t_mobile" id="t_mobile" type="tel" class="login_input" value="" placeholder="手机号码" maxlength="11" style="color:#666;"></li>

            <li class="login_line" ><img src="__PUBLIC__/Weixin/images/comment.png">
                <div style="width: 70%"><input class="login_input"  id="txtCode" name="mobile_verify" placeholder="请输入手机验证码"></div>
                <div style="width: 20%;float: right"><button class="btn btn-primary" type="button" value="" style="background: orange;" sendsms="true">验证</button></div></li>
        </ul>
        <label class="radio-inline">
            <input type="radio" name="identify" id="inlineRadio1" value="student" checked> 学生
        </label>
        <label class="radio-inline">
            <input type="radio" name="identify" id="inlineRadio2" value="teacher"> 老师
        </label>
        <button class="login_but" type="button" name="btn_login" onclick="forget();">找回密码</button>
    </form>
</div>
</body>
<script>
    $("[sendsms]").click(function(){
        var obj=$(this);
        var phone_preg1=/1[3-8]+\d{9}/;
        var phone_preg2=/^[0-9]{11}?$/;
        var phone=$("#t_mobile").val();
        if(!phone || !phone_preg1.test(phone) ||!phone_preg2.test(phone)){
            myAlert('手机号码格式不正确');
            return;
        }
       $.ajax({
           url: "{:U('Ajax/sendsms')}",
           type:"POST",
           dataType:"json",
           data:{phone:phone},
           beforeSend:function(){
               obj.attr("disabled","disabled").html("发送中...");
           },
           success:function(data){
               if(data.status==0){
                   var sum=60;
                   setinTime=setInterval(function(){
                       sum=sum-1;
                       if(sum>0){
                           obj.html(sum+"秒后重发");
                       }else{
                           obj.html("发送短信").removeAttr('disabled');
                           clearInterval(setinTime);
                       }
                   },1000);
               }else{
                   obj.html("重新发送短信").removeAttr("disabled");
                   alert(data.info);
               }
           }
       });
    });
    function forget(){
        $("#form1").submit();
    }
</script>
</html>